<style type="text/css">
.customFildset dl {
    float: left;
    display: block;
    height: 21px;
    margin: 0;
    padding: 5px 5px;
    position: relative;
    width:auto;
}

.customFildset dt {
    float: left;
    padding: 0 5px;
    line-height: 21px;
    width:104px;
}

.customFildset dd {
    display: block;
    line-height: 21px;
    float: left;
    width:177px;
}
span.error {
     left: 148px;
     top : 2px
}
</style>
<script type="text/javascript">
    function _issuedProductionOrder() {
        var mainCout = $("input[name='plannedQuantity']", $.pdialog.getCurrent()).val();
        var childCout = 0;
        $("input[name$='].plannedQuantity']", $.pdialog.getCurrent()).each(function(i,n){
            var _value = $(this).val();
            if(!_value || _value == "")
                _value = 0;
            childCout += parseFloat(_value);
        });
        if(parseFloat(mainCout)!=childCout){
            alertMsg.error("<@label key='order_planQuantity_neq.M'>子订单计划数量不等于主订单，不能下达！</@label>");
            return false;
        }else{
            $("input[name='issued']", $.pdialog.getCurrent()).val("2");
            $("#productionOrder_issued", $.pdialog.getCurrent()).submit();
        }    
    }
    
    function _saveProductionOrder() {
        $("input[name='issued']", $.pdialog.getCurrent()).val("1");
        $("#productionOrder_issued", $.pdialog.getCurrent()).submit();
    }
</script>
<form method="post" id="productionOrder_issued" action="${rc.getContextPath()}/manage/productionOrder/saveProductionOrderDetail" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">
<div class="pageContent">
    <input type="hidden" name="navTabId" value="${navTabId!''}" />
    <input type="hidden" name="issued" value="save" />
    <div class="pageFormContent customFildset">
        <fieldset>
            <dl>
                <dt><@label key='productionOrderNum.C,colon'>生产订单编号：</@label></dt>
                <dd><input type="text" name="productionOrderNum" maxlength="20" value="${productionOrder.productionOrderNum!''}" class="required" readonly="readonly"></dd>
            </dl>
            <dl>
                <dt><@label key='plannedQuantity.C,colon'>计划数量</@label></dt>
                <dd><input type="text" name="plannedQuantity" class="digits" readonly="readonly" min="0" value="${productionOrder.plannedQuantity!''}"/></dd>
            </dl>
        </fieldset>
    </div>
    <table class="table" width="100%" layoutH="140">
        <thead>
            <tr>
                <th width="40"><@label key="serialNumber.C">序号</@label></th>
                <th width="100"><@label key='workCenter_type.C'>工作中心类型</@label></th>
                <th width="100"><@label key='workCenter.C,code.C'>工作中心编号</@label></th>
                <th width="100"><@label key='workCenter.C,description.C'>工作中心描述</@label></th>
                <th width="80"><@label key='plannedQuantity.C'>计划数量</@label></th>
            </tr>
        </thead>
        <tbody>
        <#if productionOrder??><#if (productionOrder.details?size>0 )>
            <#list productionOrder.details as detail>
            <tr target="process_id" rel="${process.id!''}">
                <td>${detail_index + 1}<input type="hidden" name="details[${detail_index}].id" value="${detail.id!''}"></td>
                <td>${detail.workCenterTypeText!''}</td>
                <td>${detail.workCenterCode!''}<input type="hidden" name="details[${detail_index}].workCenterCode" value="${detail.workCenterCode!''}"/></td>
                <td>${detail.workCenterText!''}</td>
                <td><input type="text" name="details[${detail_index}].plannedQuantity" min="0" value="${detail.plannedQuantity!''}" class="required digits"/></td>
            </tr>
        </#list>
        <#else>
            <#if (productionOrder.workCenters?size>0)>
                    <#list productionOrder.workCenters as wc>
                        <tr target="process_id" rel="${process.id!''}">
                            <td>${wc_index + 1}</td>
                            <td>${wc.typeText!''}</td>
                            <td>${wc.workCenterCode!''} <input type="hidden" name="details[${wc_index}].workCenterCode" value="${wc.workCenterCode!''}"/></td>
                            <td>${wc.workCenterText!''}</td>
                            <td><input type="text" name="details[${wc_index}].plannedQuantity" value="0" min="0" class="required digits"/></td>
                        </tr>
                    </#list>
            </#if>
        </#if>
        <#else>
        <tr target="process_id">
                <td colspan="5" class="noData">======<@label key='noListData.C'>列表无数据</@label>=====</font></td>
        </tr>
        </#if>
        </tbody>
    </table>
    <div class="formBar">
        <ul>
            <li onclick="_saveProductionOrder();"><div class="buttonActive"><div class="buttonContent"><button type="button">保存</button></div></div></li>
            <li onclick="_issuedProductionOrder();"><div class="buttonActive"><div class="buttonContent"><button type="button">下达</button></div></div></li>
            <li>
                <div class="buttonActiveGrey"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
            </li>
        </ul>
    </div>
</div>
</form>
